import request from '@/router/axios';

export const getList = (current, size, params, type, startTime, endTime) => {
  return request({
    // url: '/api/beetles-offer/creativeperformance/page',
    url: '/api/beetles-offer/creative-report/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      type,
      startTime,
      endTime
    }
  })
}

export const getCreativeDetailList = (current, size, params) => {
  return request({
    // url: '/api/beetles-offer/creativeperformance/getCreativeDetailList',
    url: '/api/beetles-offer/creative-report/get-creative-detailList',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  })
}
export const getCreativePerformanceList = (params) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/creativePerformanceList',
    method: 'get',
    params: {
      ...params
    }
  })
}

export const getCreativeAllPerformanceList = (params) => {
  return request({
    // url: '/api/beetles-offer/creativeperformance/creativeAllPerformanceList',
    url: '/api/beetles-offer/creative-report/creative-all-performance-list',
    method: 'get',
    params: {
      ...params
    }
  })
}

export const getOptimizerSpendList = (params) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/optimizerSpendList',
    method: 'get',
    params: {
      ...params
    }
  })
}

export const getTagsCreativeList = (current, size, params) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/tagsCreativeList',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
export const getTagList = (params) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/tagList',
    method: 'get',
    params: {
      ...params
    }
  })
}


export const getDetail = (id) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/detail',
    method: 'get',
    params: {
      id
    }
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/submit',
    method: 'post',
    data: row
  })
}
export const selectone = (id) => {
  return request({
    url: '/api/beetles-offer/creative/selectone',
    method: 'get',
    params: {
      id: id
    }
  })
}
export const selectowneddemand = (id) => {
  return request({
    url: '/api/beetles-offer/creative/selectowneddemand',
    method: 'get',
    params: {
      owneddemandid: id
    }
  })
}
export const getSubmitter = (offerId) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/get-user-select',
    method: 'get',
    params: {
      offerId
    }
  })
}

export const getDesignerList = (offerId) => {
  return request({
    url: '/api/beetles-business/offer/get-designer-select',
    method: 'get',
    params: {
      offerId
    }
  })
}

export const exportExcel = (current, size, params, type, startTime, endTime) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/export-report',
    method: 'get',
    responseType: 'blob',
    params: {
      ...params,
      current,
      size,
      type,
      startTime,
      endTime
    }
  })
}
export const checkDataSum = (params) => {
  return request({
    url: '/api/beetles-offer/creativeperformance/check_data_sum',
    method: 'get',
    params: {
      ...params
    }
  })
}
// 获取模板type=1效果报告 ,type=2 广告分析模版
export const getTemplateList = (offerId, type) => {
  return request({
    url: '/api/beetles-offer/creative-report/get-own-template',
    method: 'get',
    params: {offerId, type}
  });
}
// 保存模板
export const saveTemplate = (data) => {
  return request({
    url: '/api/beetles-offer/creative-report/save-update-template',
    method: 'post',
    data
  });
}

// 删除模板
export const deleteTemplate = (ids) => {
  return request({
    url: '/api/beetles-offer/creative-report/remove-template',
    method: 'delete',
    params: {ids}
  });
}
// 获取媒体事件
export const getEventCreativeGroup = (offerId) => {
  return request({
    url: '/api/beetles-offer/creative-report/get-event-creative-group',
    method: 'get',
    params: {offerId}
  });
}

// 获取广告分析媒体事件
export const getEventCreativeAdGroup = (offerId) => {
  return request({
    url: '/api/beetles-offer/creative-report/get-event-ad-group',
    method: 'get',
    params: {offerId}
  });
}
// 获取列表
export const getCreativeReportList = (params, data) => {
  return request({
    url: '/api/beetles-offer/creative-report/page',
    method: 'POST',
    params,
    data
  })
}
//
export const exportExcel2 = params => {
  return request({
    url: '/api/beetles-offer/creativeperformance/export-report',
    method: 'get',
    responseType: 'blob',
    params
  })
}

export const getList2 = (params, data) => {
  return request({
    url: '/api/beetles-offer/creative-report/page',
    method: 'POST',
    params,
    data
  })
}

// 获取优化时
export const getOptimizerList = (offerId) => {
  return request({
    url: '/api/offer/get-optimizer-select',
    method: 'get',
    params: {
      offerId
    }
  })
}

// 提交kpi指标
export const submitKpiConfig = data => {
  return request({
    url: '/api/beetles-offer/kpi/config/submit',
    method: 'POST',
    data
  })
}

// 获取kpi配置
export const getKpiConfig = params => {
  return request({
    url: '/api/beetles-offer/kpi/config/getKpiConfigByOfferId',
    method: 'get',
    params
  })
}


//素材效果排行
export const getCreativePerformanceRanking = params => {
  return request({
    url: '/api/beetles-offer/creativeperformance/creative-performance-ranking',
    method: 'get',
    params,
  })
}
